﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebShopData;

namespace GalaxySale2014
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LoginGS2014_Authenticate(object sender, AuthenticateEventArgs e)
        {
            User currentUser = UserData.Authenticate(LoginGS2014.UserName, LoginGS2014.Password);
            if (currentUser != null)
            {
                currentUser.PassWord = "";
                Session["CurrentUser"] = currentUser;
                Order currentOrder = Session["CurrentOrder"] as Order;
                currentOrder.UserId = currentUser.UserId;
                currentOrder.FirstName = currentUser.FirstName;
                currentOrder.LastName = currentUser.LastName;
                currentOrder.Address = currentUser.Address;
                currentOrder.Zip = currentUser.Zip;
                currentOrder.City = currentUser.City;
                currentOrder.Email = currentUser.Email;
                Session["CurrentOrder"] = currentOrder;
                Response.Redirect(@"~/Default.aspx");
            }
        }
    }
}